#include "BaseObject.h"
#include "../Wrapper/CSGD_TextureManager.h"

BaseObject::BaseObject()
{
	objType = OBJ_BASE;
	refCount = 1;

	SetPositionX(0);
	SetPositionY(0);
	SetWidth(0);
	SetHeight(0);
	SetVelocityX(0);
	SetVelocityY(0);
	SetRotation(0);
	SetIsActive(true);
	SetImageID(-1);
}

BaseObject::~BaseObject()
{
}

void BaseObject::Update(float _dT)
{
}

void BaseObject::Render()
{
	CSGD_TextureManager::GetInstance()->Draw(imageID, (int)(posX), (int)(posY),
											1.0f, 1.0f, 0, width * 0.5f, height * 0.5f, 
											D3DXToRadian(rotation));
}

RECT BaseObject::GetCollisionRect()
{
	RECT collisionRect = {0, 0, 0, 0};

	return collisionRect;
}

bool BaseObject::CheckCollision(BaseInterface* _base)
{
	RECT checkRect;

	if(IntersectRect(&checkRect, &GetCollisionRect(), &_base->GetCollisionRect()))
		return true;

	return false;
}

void BaseObject::AddRef()
{
	refCount++;
}

void BaseObject::Release()
{
	refCount--;
	if(refCount <= 0)
		delete this;
}